Program on Applet and JDBC
import java.sql.*;
import java.applet.*;
import java.awt.*;
public class Sample extends Applet
{
Connection con=null;
public void init()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:
@localhost:1521:orcl”,"scott","tiger");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
public void paint(Graphics g)
{
try
{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(“select * from emp”);
while(rs.next())
{
g.drawString(rs.getString(1),10,20);
}
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}